<?php

namespace app\modules\merchant\controllers;

use app\common\controllers\AccessController;
use app\modules\merchant\forms\home\UpdatePasswordForm;
use app\modules\merchant\services\HomeService;
use Yii;
use yii\base\UserException;

class HomeController extends AccessController {

    //获取登陆者信息
    public function actionUser(){
        return HomeService::userInfo() ;
    }

    //修改密码
    public function actionUpdatePassword()
    {
        $form = new UpdatePasswordForm();
        if($form->load(Yii::$app->getRequest()->post(),'') && HomeService::updatePassword($form)) {
            return "";
        }else{
            throw new UserException(HomeService::getError());
        }
    }
}